// src/stores/auth.js
import { defineStore } from 'pinia';

export const useAuthStore = defineStore('auth', {
  state: () => ({
    user: null,
    token: null,
  }),
  actions: {
    // 获取当前认证信息
    getAuth() {
      console.log('getAuth called:', { user: this.user,token: this.token });
      return {
        user: this.user,
        token: this.token,
      };
    },
    // 设置认证信息
    setAuth(user,token) {
      this.user = user;
      this.token = token;
    },
    // 注销用户
    logout() {
      this.user = null;
      this.token = null;
    },
  },
});